package com.pj.lib.auraServer.app.properties;

import java.util.Map;



public class AuraProperties implements Properties{

	/**
	 *  period between checking if there are no events
	 */
	public static final String KEY_CHECK_AURA_EVENTS_REFRESH_TIME = "1";
	/**
	 *  sending locations to clients period time
	 */
	public static final String KEY_SERVER_LOCATION_REFRESH_TIME = "2"; 
	/**
	 * boolean:
		if true - showing not logged users (must get this data from db)
		if false - showing only logged users (doesn't require to get data from db)
	 */
	public static final String KEY_SHOW_NOT_LOGGED_USERS = "3";
	
	public int CHECK_AURA_EVENTS_REFRESH_TIME;
	public int SERVER_LOCATION_REFRESH_TIME;
	public boolean SHOW_NOT_LOGGED_USERS;
	
	
	@Override
	public void getSettingsFromFile(String fileName) {
		// TODO z pliku
		
	}

	@Override
	public void getSettingsFromMap(Map map) {
		CHECK_AURA_EVENTS_REFRESH_TIME = (Integer) map.get(KEY_CHECK_AURA_EVENTS_REFRESH_TIME);
		SERVER_LOCATION_REFRESH_TIME = (Integer) map.get(KEY_SERVER_LOCATION_REFRESH_TIME);
		SHOW_NOT_LOGGED_USERS = (Boolean) map.get(KEY_SHOW_NOT_LOGGED_USERS);
	}

	@Override
	public void getSettingsFromProperties(java.util.Properties props) {
		CHECK_AURA_EVENTS_REFRESH_TIME = Integer.valueOf(props.getProperty(KEY_CHECK_AURA_EVENTS_REFRESH_TIME));
		SERVER_LOCATION_REFRESH_TIME = Integer.valueOf(props.getProperty(KEY_SERVER_LOCATION_REFRESH_TIME));
		if(props.getProperty(KEY_SHOW_NOT_LOGGED_USERS).toUpperCase() == "Y") {
			SHOW_NOT_LOGGED_USERS = true;
		} else {
			SHOW_NOT_LOGGED_USERS = false;
		}
		
	}
	
}
